[ASP.NET] IIS7 downloading file length
        Posted  
        
            by GTD
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by GTD
        
        
        
        Published on 2009-09-12T19:09:41Z
        Indexed on 
            2010/04/30
            10:47 UTC
        
        
        Read the original article
        Hit count: 364
        
I've following code for file download:
        FileInfo fileInfo = new FileInfo(filePath);
        context.Response.Clear();
        context.Response.ContentType = "application/octet-stream";
        context.Response.AddHeader("Content-Disposition", "attachment; filename=" + System.IO.Path.GetFileName(filePath));
        context.Response.AddHeader("Content-Length", fileInfo.Length.ToString());
        context.Response.WriteFile(filePath);
        context.Response.End();
When I run it on my local IIS6 it works fine. Web browser (tested on IE8, Firefox 3.5.2, Opera 10) shows file length before I start download the file.
When I run this code on remote IIS7, web browser doesn't shows file length. File length is unknown.
Why I don't get file length when this code runs under IIS7?
© Stack Overflow or respective owner